package com.superm.controller;

import com.superm.entity.Stock;
import com.superm.entity.SumOrderDetails;
import com.superm.service.StockService;
import com.superm.service.SumService;
import com.superm.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(path="/sum")
public class SumController {
    @Autowired
    private SumService sumService;
    @GetMapping(path = "/SumStock")
    public String sumStock(){
        return "summary/SumStock";
    }
    @RequestMapping(path = "/SumStock")
    @ResponseBody
    public List<Stock> sumStock1(){
        return  sumService.sumStock();
    }
    @GetMapping(path = "/sumPrice")
    public ModelAndView sumPrice(){
        ModelAndView ma = new ModelAndView( "summary/SumRetail");
        ma.addObject("Year",sumService.showYear());
        return ma;
    }
    @PostMapping(path = "/sumPrice")
    @ResponseBody
    public List<SumOrderDetails> sumPrice(String year){
        return sumService.sumYear(year);
    }
}
